package com.jill.Controller;

import com.jill.Pojo.Article;
import com.jill.Pojo.Result;
import com.jill.Service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@CrossOrigin
@RestController
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    @GetMapping("/index")
    public Result index(){

        List<Article>list=articleService.index();

        return Result.success(list);
    }

    @GetMapping("/findByCate")
    public Result findByCate(Integer id){
        List<Article>list=articleService.findByCate(id);


        return Result.success(list);
    }

    @PostMapping("/addCount")
    public Result addCount(@RequestBody Article article){
        articleService.addCount(article.getId());
        return Result.success();
    }

    @GetMapping("/hotArticle")
    public Result hotArticle(){
        return Result.success(articleService.hotArticle());
    }
}
